import { Color, Name, User } from './lxdy';
import { colors, names } from './cldy';

export const getRandomElement = <T,>(list: T[]): T => 
  list[Math.floor(Math.random() * list.length)];

export const getRandomColor = (): Color => getRandomElement(colors);
export const getRandomName = (): Name => getRandomElement(names);

export const getInitialUser = (): User => ({
  name: getRandomName(),
  color: getRandomColor(),
});